﻿using System.Reflection;
using System.Configuration;
using ATSIDAL;
using ATSDAL;
 

namespace DALFactory
{
    public sealed class DataAccess
    {
        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];

        private DataAccess() { }

        //有需要的时候，这个函数可以单独提取出来建一个类，管理与配置文件相关的各种动态对象的创建、维护
        public static object LocateDALObject(string className)
        {
            string fullPath = path + "." + className;
            return Assembly.Load(path).CreateInstance(fullPath);
        }

        //-------------------------------------以下为天线相关---------------------------------------------------------

        public static ATSIDAL.ITProductType CreateTProductType()
        {
            return (ATSIDAL.ITProductType)LocateDALObject("TProductType");
        }

        public static ATSIDAL.ITMO CreateTMO()
        {
            return (ATSIDAL.ITMO)LocateDALObject("TMO");
        }

        public static ATSIDAL.ITHouse CreateTHouse()
        {
            return (ATSIDAL.ITHouse)LocateDALObject("THouse");
        }


        //-------------------------------------以下为天线电性能测试相关---------------------------------------------------------

        public static ATSIDAL.ITTest CreateTTest()
        {
            return (ATSIDAL.ITTest)LocateDALObject("TTest");
        }

        public static ATSIDAL.ITTestItem CreateTTestItem()
        {
            return (ATSIDAL.ITTestItem)LocateDALObject("TTestItem");
        }



        //-------------------------------------以下为天线交调测试相关---------------------------------------------------------

        public static ATSIDAL.IPIMTest CreatePIMTset()
        {
            return (ATSIDAL.IPIMTest)LocateDALObject("PIMTest");
        }

        public static ATSIDAL.IPIMTestItem CreatePIMTsetItem()
        {
            return (ATSIDAL.IPIMTestItem)LocateDALObject("PIMTsetItem");
        }

        //--------------------------------------以下为生成报表相关-------------------------------------------------------------------
        public static ATSIDAL.IElectReport CreatElecReport()
        {
            return (ATSIDAL.IElectReport)LocateDALObject("ElectReport");
        }

        public static ATSIDAL.IPIMReport CreatPIMReport()
        {
            return (ATSIDAL.IPIMReport)LocateDALObject("PIMReport");
        }

        public static ATSIDAL.ITPTReport CreatTRPeport()
        {
            return (ATSIDAL.ITPTReport)LocateDALObject("TRPeport");
        }

   

        public static ATSIDAL.IElecBatchReport CreateElecBatchReport()
        {
            return (ATSIDAL.IElecBatchReport)LocateDALObject("ElecBatchReport");
        }

        public static ATSIDAL.IPIMBatchReport CreatePIMBatchReport()
        {
            return (ATSIDAL.IPIMBatchReport)LocateDALObject("PIMBatchReport");
        }

        public static ATSIDAL.IPIMRepair CreatePIMRepairReport()
        {
            return (ATSIDAL.IPIMRepair)LocateDALObject("PIMRepairReport");
        }


        //--------------------------------------以下为天线调试信息报表相关-------------------------------------------------------------------
        public static ATSIDAL.IDebReport CreateDebReport()
        {
            return (ATSIDAL.IDebReport)LocateDALObject("DebReport");
        }


        //-------------------------------------添加测试员信息-----------------------------------------------------------
        public static ATSIDAL.IRole CreateRole()
        {
            return (ATSIDAL.IRole)LocateDALObject("Role");
        }

        //-------------产品状态----------------------------

        //------------打印数据----------------------------
        public static IPrintRecord CreatePrintRecord()
        {
            return (ATSIDAL.IPrintRecord)LocateDALObject("tb_PrintRecord");
        }


        //----------包装信息--------------

        public static ITPackage CreateTPackage()
        {
            return (ITPackage)LocateDALObject("TPackageDal");
        }
        //--------包装配置信息----------
        public static ITPackConfig CreateTPackConfig()
        {
            return (ITPackConfig)LocateDALObject("TPackConfigDal");
        }

        public static IAllStatus CreateAllStatus()
        {
            return (ATSIDAL.IAllStatus)LocateDALObject("AllStatusDal");
        }

        //---成品标签打印信息------------
        public static ITPrintRecord CreateTPrintRecord()
        {
            return (ITPrintRecord)LocateDALObject("TPrintRecordDal");
        }
        //----关联信息--------
        public static ITRelevance CreateTRelevance()
        {
            return (ITRelevance)LocateDALObject("TRelevanceDal");
        }

        //----气密信息----
        public static IAirtightness CreateAirtightness()
        {
            return (IAirtightness)LocateDALObject("AirtightnessDal");
        }

        //----气密配置信息----
      
        public static IAirtightnessConfig CreateAirtightnessConfig()
        {
            return (IAirtightnessConfig)LocateDALObject("AirtightnessConfigDal"); 
        }

        public static ITPackRemark CreateTPackRemark()
        {
            return (ITPackRemark)LocateDALObject("TPackRemarkDal"); 
        }
        //----校验-----
        public static ATSIDAL.ITCalibration CreateTCalibration()
        {
            return (ATSIDAL.ITCalibration)LocateDALObject("TCalibration");
        }

        public static ATSIDAL.ITCalibrationItem CreateTCalibrationItem()
        {
            return (ATSIDAL.ITCalibrationItem)LocateDALObject("TCalibrationItem");
        }

        public static ATSIDAL.ITCalIntermodulationItem CreateTCalIntermodulation()
        {
            return (ATSIDAL.ITCalIntermodulationItem)LocateDALObject("TCalIntermodulation");
        }

        public static ATSIDAL.ITCalElectricalPropertyItem CreateCalElectricalProperty()
        {
            return (ATSIDAL.ITCalElectricalPropertyItem)LocateDALObject("TCalElectricalProperty");
        }

       
    }
}
